package org.kealinghornets.jchuah.buttons;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;


public class Level2Activity extends MainActivity {

    public void checkVictory(){
        View imageView = findViewById(R.id.imageView);
        if (imageView.getVisibility() == View.INVISIBLE  ) {
            Toast.makeText(this, "YOU WIN", Toast.LENGTH_SHORT).show();
            Toast.makeText(this, "Taking you to Level 3!", Toast.LENGTH_LONG).show();
            startActivity(new Intent(this, Level3Activity.class));
        }
    }

    public void togglebutton(int id) {
        View button=findViewById(id);
        if (button.getVisibility()==View.VISIBLE) {
            button.setVisibility(View.INVISIBLE);
        }else {
            button.setVisibility(View.VISIBLE);
        }
    }
    public void togglestar(int id){
        View star=findViewById(id);
        if (star.getVisibility()==View.VISIBLE) {
            star.setVisibility(View.INVISIBLE);
        }else {
            star.setVisibility(View.VISIBLE);

        }
    }
    public void onButton6Push(View view){
        togglebutton(R.id.button8); checkVictory();
    }
    public void onButton11Push (View view){
        togglebutton(R.id.button9);
        togglebutton(R.id.button10);
        checkVictory();
    }
    public void onButton8Push (View view){
        togglebutton(R.id.button11);checkVictory();
    }
    public void onButton10Push(View view){
        togglebutton(R.id.button7); checkVictory();
    }
    public void onButton9Push(View view) {
        togglebutton(R.id.button11);
        togglebutton(R.id.button8);
        togglebutton(R.id.button10);
        checkVictory();
    }
    public void onButton7Push (View view) {
        togglestar (R.id.imageView);
        checkVictory();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_level2);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_level2, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
